<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <script src="${pageContext.request.contextPath}/static/js/jquery.js"></script>

    <script>
        $("document").ready(()=>{
            $.get({
                url:"${pageContext.request.contextPath}/ajax2",
                data:null,
                success:(res)=>{
                    console.log(res);
                    let html = "";

                    for(let i = 0;i<res.length;i++){
                        html += `<tr>`
                        html += `<td>\${res[i].name}</td>`
                        html += `<td>\${res[i].age}</td>`
                        html += `</tr>`
                    }

                    console.log(html)
                    $("#context").html(html)
                }
            })
        })
    </script>
</head>
<body>
    <table>
        <tr>
            <td>姓名</td>
            <td>年龄</td>
        </tr>
        <tbody id="context">

        </tbody>
    </table>
</body>
</html>
